#pragma once
#include "../geometries/BufferGeometry.h"
#include "../core/Node3D.h"
#include "../core/materials/Material.h"
POCELAIN_NAMESPACE_BEGIN
class Mesh : public Node3D
{
public:
    Mesh(BufferGeometry *geometry,Material *material)
    {
        geometry->retain();
        mGeometry = geometry;
        material->retain();
        mMaterial = material;
    }

    virtual ~Mesh()
    {
        if(mGeometry!=nullptr)
        {
            mGeometry->release();
        }
        if(mMaterial!=nullptr)
        {
            mMaterial->release();
        }
    }
    virtual bool isMesh() const override {return true;}
    virtual EObjectClass getObjectClass() const override {return EObjectClass::E_MESH;}
    Material *getMaterial()const {return mMaterial;}
    BufferGeometry *getGeometry()const {return mGeometry;}
private:
    BufferGeometry *mGeometry = nullptr;
    Material *mMaterial = nullptr;

    //void raycast();
};
POCELAIN_NAMESPACE_END
